

        INCLUDE kxarm.h
        INCLUDE armmacros.s
        
        TEXTAREA
         

        LEAF_ENTRY Power_Idle

        MCR p15,0,r0,c7,c0,4

        RETURN 

;;;
;;; EnterStandby(addr)
;;; call standby code
        LEAF_ENTRY EnterStandby
        stmdb sp!, {r0-r12}
        mov r5,pc
        mov pc,r0       ; r0 normally is the copy code of Standby
        nop
        nop
        nop
        ldmia sp!, {r0-r12}

        RETURN 

        LEAF_ENTRY Standby

        ldr r0, =0xa802d000         ;0x2002d000,set ram refresh
        ldr r1, [pc, #MEM_CMD-(.+8)]
        str r1, [r0]
        
        ldr r0, =0xa802d000
        ldr r1, [pc, #(MEM_CMD+4)-(.+8)]
        str r1, [r0]

        ldr r0, =0xa8100004         ;0x08000004,enter standby
        ldr r1, [r0]
        orr r1, r1, #8192
        str r1, [r0]
        
        ldr r0, =0xa802d000         ;0x2002d000,unset ram refresh
        ldr r1, [pc, #(MEM_CMD+8)-(.+8)]
        str r1, [r0]

        ldr r0, =0xa802d000
        ldr r1, [pc, #(MEM_CMD+12)-(.+8)]
        str r1, [r0]
        
    ;bl to c function
        add r5, r5, #8
        mov pc, r5
        nop

        LTORG

MEM_CMD 
        DCD 0x12345678      ; end flag for copy part, replaced to mem controlor command before run code
        DCD 0x23456789
        DCD 0x98765432
        DCD 0x87654321

      END

